{
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "# Drop Highly Correlated Features"
      ],
      "metadata": {}
    },
    {
      "cell_type": "markdown",
      "source": [
        "Feature selection is a removing unnecessary features."
      ],
      "metadata": {}
    },
    {
      "cell_type": "code",
      "source": [
        "# Importing the libraries\n",
        "import pandas as pd\n",
        "import numpy as np\n",
        "import matplotlib.pyplot as plt\n",
        "\n",
        "import warnings\n",
        "warnings.filterwarnings(\"ignore\")\n",
        "\n",
        "# yfinance is used to fetch data \n",
        "import yfinance as yf\n",
        "yf.pdr_override()"
      ],
      "outputs": [],
      "execution_count": 1,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2020-09-04T02:06:04.530Z",
          "iopub.execute_input": "2020-09-04T02:06:04.535Z",
          "iopub.status.idle": "2020-09-04T02:06:05.586Z",
          "shell.execute_reply": "2020-09-04T02:06:05.606Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# input\n",
        "symbol = 'AMD'\n",
        "start = '2014-01-01'\n",
        "end = '2018-08-27'\n",
        "\n",
        "# Read data \n",
        "dataset = yf.download(symbol,start,end)\n",
        "\n",
        "# View columns \n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[*********************100%***********************]  1 of 1 completed\n"
          ]
        },
        {
          "output_type": "execute_result",
          "execution_count": 2,
          "data": {
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Adj Close</th>\n      <th>Close</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Open</th>\n      <th>Volume</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-02</th>\n      <td>3.95</td>\n      <td>3.95</td>\n      <td>3.98</td>\n      <td>3.84</td>\n      <td>3.85</td>\n      <td>20548400</td>\n    </tr>\n    <tr>\n      <th>2014-01-03</th>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>3.98</td>\n      <td>22887200</td>\n    </tr>\n    <tr>\n      <th>2014-01-06</th>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.01</td>\n      <td>42398300</td>\n    </tr>\n    <tr>\n      <th>2014-01-07</th>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.19</td>\n      <td>42932100</td>\n    </tr>\n    <tr>\n      <th>2014-01-08</th>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.23</td>\n      <td>30678700</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
            "text/plain": "            Adj Close  Close  High   Low  Open    Volume\nDate                                                    \n2014-01-02       3.95   3.95  3.98  3.84  3.85  20548400\n2014-01-03       4.00   4.00  4.00  3.88  3.98  22887200\n2014-01-06       4.13   4.13  4.18  3.99  4.01  42398300\n2014-01-07       4.18   4.18  4.25  4.11  4.19  42932100\n2014-01-08       4.18   4.18  4.26  4.14  4.23  30678700"
          },
          "metadata": {}
        }
      ],
      "execution_count": 2,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2020-09-04T02:06:05.593Z",
          "iopub.execute_input": "2020-09-04T02:06:05.597Z",
          "iopub.status.idle": "2020-09-04T02:06:06.889Z",
          "shell.execute_reply": "2020-09-04T02:06:06.926Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "dataset['Increase_Decrease'] = np.where(dataset['Volume'].shift(-1) > dataset['Volume'],1,0)\n",
        "dataset['Buy_Sell_on_Open'] = np.where(dataset['Open'].shift(-1) > dataset['Open'],1,0)\n",
        "dataset['Buy_Sell'] = np.where(dataset['Adj Close'].shift(-1) > dataset['Adj Close'],1,0)\n",
        "dataset['Returns'] = dataset['Adj Close'].pct_change()\n",
        "dataset = dataset.dropna()\n",
        "dataset.head()"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 3,
          "data": {
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Adj Close</th>\n      <th>Close</th>\n      <th>High</th>\n      <th>Low</th>\n      <th>Open</th>\n      <th>Volume</th>\n      <th>Increase_Decrease</th>\n      <th>Buy_Sell_on_Open</th>\n      <th>Buy_Sell</th>\n      <th>Returns</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-03</th>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>4.00</td>\n      <td>3.88</td>\n      <td>3.98</td>\n      <td>22887200</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.012658</td>\n    </tr>\n    <tr>\n      <th>2014-01-06</th>\n      <td>4.13</td>\n      <td>4.13</td>\n      <td>4.18</td>\n      <td>3.99</td>\n      <td>4.01</td>\n      <td>42398300</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.032500</td>\n    </tr>\n    <tr>\n      <th>2014-01-07</th>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>4.25</td>\n      <td>4.11</td>\n      <td>4.19</td>\n      <td>42932100</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.012106</td>\n    </tr>\n    <tr>\n      <th>2014-01-08</th>\n      <td>4.18</td>\n      <td>4.18</td>\n      <td>4.26</td>\n      <td>4.14</td>\n      <td>4.23</td>\n      <td>30678700</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>2014-01-09</th>\n      <td>4.09</td>\n      <td>4.09</td>\n      <td>4.23</td>\n      <td>4.05</td>\n      <td>4.20</td>\n      <td>30667600</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.021531</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
            "text/plain": "            Adj Close  Close  High   Low  Open    Volume  Increase_Decrease  \\\nDate                                                                          \n2014-01-03       4.00   4.00  4.00  3.88  3.98  22887200                  1   \n2014-01-06       4.13   4.13  4.18  3.99  4.01  42398300                  1   \n2014-01-07       4.18   4.18  4.25  4.11  4.19  42932100                  0   \n2014-01-08       4.18   4.18  4.26  4.14  4.23  30678700                  0   \n2014-01-09       4.09   4.09  4.23  4.05  4.20  30667600                  0   \n\n            Buy_Sell_on_Open  Buy_Sell   Returns  \nDate                                              \n2014-01-03                 1         1  0.012658  \n2014-01-06                 1         1  0.032500  \n2014-01-07                 1         0  0.012106  \n2014-01-08                 0         0  0.000000  \n2014-01-09                 0         1 -0.021531  "
          },
          "metadata": {}
        }
      ],
      "execution_count": 3,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2020-09-04T02:06:06.897Z",
          "iopub.execute_input": "2020-09-04T02:06:06.903Z",
          "shell.execute_reply": "2020-09-04T02:06:06.929Z",
          "iopub.status.idle": "2020-09-04T02:06:06.938Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Create correlation matrix\n",
        "corr_matrix = dataset.corr().abs()\n",
        "\n",
        "# Select upper triangle of correlation matrix\n",
        "upper = corr_matrix.where(np.triu(np.ones(corr_matrix.shape), k=1).astype(np.bool))\n",
        "\n",
        "# Find index of feature columns with correlation greater than 0.95\n",
        "to_drop = [column for column in upper.columns if any(upper[column] > 0.95)]"
      ],
      "outputs": [],
      "execution_count": 4,
      "metadata": {
        "collapsed": false,
        "outputHidden": false,
        "inputHidden": false,
        "execution": {
          "iopub.status.busy": "2020-09-04T02:06:06.945Z",
          "iopub.execute_input": "2020-09-04T02:06:06.950Z",
          "iopub.status.idle": "2020-09-04T02:06:06.957Z",
          "shell.execute_reply": "2020-09-04T02:06:07.026Z"
        }
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Drop features \n",
        "dataset.drop(dataset[to_drop], axis=1)"
      ],
      "outputs": [
        {
          "output_type": "execute_result",
          "execution_count": 5,
          "data": {
            "text/html": "<div>\n<style scoped>\n    .dataframe tbody tr th:only-of-type {\n        vertical-align: middle;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n\n    .dataframe thead th {\n        text-align: right;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>Adj Close</th>\n      <th>Volume</th>\n      <th>Increase_Decrease</th>\n      <th>Buy_Sell_on_Open</th>\n      <th>Buy_Sell</th>\n      <th>Returns</th>\n    </tr>\n    <tr>\n      <th>Date</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>2014-01-03</th>\n      <td>4.000000</td>\n      <td>22887200</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.012658</td>\n    </tr>\n    <tr>\n      <th>2014-01-06</th>\n      <td>4.130000</td>\n      <td>42398300</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.032500</td>\n    </tr>\n    <tr>\n      <th>2014-01-07</th>\n      <td>4.180000</td>\n      <td>42932100</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.012106</td>\n    </tr>\n    <tr>\n      <th>2014-01-08</th>\n      <td>4.180000</td>\n      <td>30678700</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>2014-01-09</th>\n      <td>4.090000</td>\n      <td>30667600</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.021531</td>\n    </tr>\n    <tr>\n      <th>2014-01-10</th>\n      <td>4.170000</td>\n      <td>20840800</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.019560</td>\n    </tr>\n    <tr>\n      <th>2014-01-13</th>\n      <td>4.130000</td>\n      <td>22856100</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.009592</td>\n    </tr>\n    <tr>\n      <th>2014-01-14</th>\n      <td>4.300000</td>\n      <td>42434800</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.041162</td>\n    </tr>\n    <tr>\n      <th>2014-01-15</th>\n      <td>4.470000</td>\n      <td>66613100</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.039535</td>\n    </tr>\n    <tr>\n      <th>2014-01-16</th>\n      <td>4.380000</td>\n      <td>46975600</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-0.020134</td>\n    </tr>\n    <tr>\n      <th>2014-01-17</th>\n      <td>4.180000</td>\n      <td>45842700</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0</td>\n      <td>-0.045662</td>\n    </tr>\n    <tr>\n      <th>2014-01-21</th>\n      <td>4.170000</td>\n      <td>58702900</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-0.002392</td>\n    </tr>\n    <tr>\n      <th>2014-01-22</th>\n      <td>3.670000</td>\n      <td>86329500</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-0.119904</td>\n    </tr>\n    <tr>\n      <th>2014-01-23</th>\n      <td>3.620000</td>\n      <td>29844700</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-0.013624</td>\n    </tr>\n    <tr>\n      <th>2014-01-24</th>\n      <td>3.470000</td>\n      <td>48095800</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-0.041436</td>\n    </tr>\n    <tr>\n      <th>2014-01-27</th>\n      <td>3.410000</td>\n      <td>31332300</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.017291</td>\n    </tr>\n    <tr>\n      <th>2014-01-28</th>\n      <td>3.540000</td>\n      <td>27962600</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.038123</td>\n    </tr>\n    <tr>\n      <th>2014-01-29</th>\n      <td>3.480000</td>\n      <td>21765000</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-0.016949</td>\n    </tr>\n    <tr>\n      <th>2014-01-30</th>\n      <td>3.480000</td>\n      <td>17111700</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0.000000</td>\n    </tr>\n    <tr>\n      <th>2014-01-31</th>\n      <td>3.430000</td>\n      <td>13602100</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-0.014368</td>\n    </tr>\n    <tr>\n      <th>2014-02-03</th>\n      <td>3.330000</td>\n      <td>22280200</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.029155</td>\n    </tr>\n    <tr>\n      <th>2014-02-04</th>\n      <td>3.370000</td>\n      <td>22681000</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.012012</td>\n    </tr>\n    <tr>\n      <th>2014-02-05</th>\n      <td>3.310000</td>\n      <td>14858900</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.017804</td>\n    </tr>\n    <tr>\n      <th>2014-02-06</th>\n      <td>3.410000</td>\n      <td>16072900</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.030212</td>\n    </tr>\n    <tr>\n      <th>2014-02-07</th>\n      <td>3.470000</td>\n      <td>23119700</td>\n      <td>0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.017595</td>\n    </tr>\n    <tr>\n      <th>2014-02-10</th>\n      <td>3.630000</td>\n      <td>21241100</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.046110</td>\n    </tr>\n    <tr>\n      <th>2014-02-11</th>\n      <td>3.700000</td>\n      <td>34198100</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.019284</td>\n    </tr>\n    <tr>\n      <th>2014-02-12</th>\n      <td>3.690000</td>\n      <td>18321300</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.002703</td>\n    </tr>\n    <tr>\n      <th>2014-02-13</th>\n      <td>3.700000</td>\n      <td>13368600</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.002710</td>\n    </tr>\n    <tr>\n      <th>2014-02-14</th>\n      <td>3.690000</td>\n      <td>12387900</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.002703</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>2018-07-16</th>\n      <td>16.580000</td>\n      <td>65275300</td>\n      <td>0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.019053</td>\n    </tr>\n    <tr>\n      <th>2018-07-17</th>\n      <td>16.870001</td>\n      <td>42313500</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.017491</td>\n    </tr>\n    <tr>\n      <th>2018-07-18</th>\n      <td>16.850000</td>\n      <td>40881500</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-0.001186</td>\n    </tr>\n    <tr>\n      <th>2018-07-19</th>\n      <td>16.709999</td>\n      <td>41267800</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-0.008309</td>\n    </tr>\n    <tr>\n      <th>2018-07-20</th>\n      <td>16.500000</td>\n      <td>42879800</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.012567</td>\n    </tr>\n    <tr>\n      <th>2018-07-23</th>\n      <td>16.660000</td>\n      <td>44940800</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.009697</td>\n    </tr>\n    <tr>\n      <th>2018-07-24</th>\n      <td>16.190001</td>\n      <td>58201500</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-0.028211</td>\n    </tr>\n    <tr>\n      <th>2018-07-25</th>\n      <td>16.049999</td>\n      <td>82604900</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>-0.008647</td>\n    </tr>\n    <tr>\n      <th>2018-07-26</th>\n      <td>18.350000</td>\n      <td>192661100</td>\n      <td>0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.143302</td>\n    </tr>\n    <tr>\n      <th>2018-07-27</th>\n      <td>18.940001</td>\n      <td>161903800</td>\n      <td>0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.032153</td>\n    </tr>\n    <tr>\n      <th>2018-07-30</th>\n      <td>19.420000</td>\n      <td>160823400</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0.025343</td>\n    </tr>\n    <tr>\n      <th>2018-07-31</th>\n      <td>18.330000</td>\n      <td>118403400</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.056128</td>\n    </tr>\n    <tr>\n      <th>2018-08-01</th>\n      <td>18.480000</td>\n      <td>75495200</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0.008183</td>\n    </tr>\n    <tr>\n      <th>2018-08-02</th>\n      <td>18.790001</td>\n      <td>52867100</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.016775</td>\n    </tr>\n    <tr>\n      <th>2018-08-03</th>\n      <td>18.490000</td>\n      <td>53232100</td>\n      <td>1</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.015966</td>\n    </tr>\n    <tr>\n      <th>2018-08-06</th>\n      <td>19.430000</td>\n      <td>83579700</td>\n      <td>0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.050838</td>\n    </tr>\n    <tr>\n      <th>2018-08-07</th>\n      <td>19.559999</td>\n      <td>72822600</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0.006691</td>\n    </tr>\n    <tr>\n      <th>2018-08-08</th>\n      <td>19.580000</td>\n      <td>52081400</td>\n      <td>0</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0.001023</td>\n    </tr>\n    <tr>\n      <th>2018-08-09</th>\n      <td>19.100000</td>\n      <td>46653400</td>\n      <td>1</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-0.024515</td>\n    </tr>\n    <tr>\n      <th>2018-08-10</th>\n      <td>19.059999</td>\n      <td>65821100</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>-0.002094</td>\n    </tr>\n    <tr>\n      <th>2018-08-13</th>\n      <td>19.730000</td>\n      <td>81411300</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.035152</td>\n    </tr>\n    <tr>\n      <th>2018-08-14</th>\n      <td>20.020000</td>\n      <td>89195500</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0.014698</td>\n    </tr>\n    <tr>\n      <th>2018-08-15</th>\n      <td>19.700001</td>\n      <td>86355700</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>-0.015984</td>\n    </tr>\n    <tr>\n      <th>2018-08-16</th>\n      <td>19.330000</td>\n      <td>69733700</td>\n      <td>0</td>\n      <td>0</td>\n      <td>1</td>\n      <td>-0.018782</td>\n    </tr>\n    <tr>\n      <th>2018-08-17</th>\n      <td>19.770000</td>\n      <td>60616600</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.022763</td>\n    </tr>\n    <tr>\n      <th>2018-08-20</th>\n      <td>19.980000</td>\n      <td>62983200</td>\n      <td>0</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.010622</td>\n    </tr>\n    <tr>\n      <th>2018-08-21</th>\n      <td>20.400000</td>\n      <td>55629000</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.021021</td>\n    </tr>\n    <tr>\n      <th>2018-08-22</th>\n      <td>20.900000</td>\n      <td>62002700</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.024510</td>\n    </tr>\n    <tr>\n      <th>2018-08-23</th>\n      <td>22.290001</td>\n      <td>113444100</td>\n      <td>1</td>\n      <td>1</td>\n      <td>1</td>\n      <td>0.066507</td>\n    </tr>\n    <tr>\n      <th>2018-08-24</th>\n      <td>23.980000</td>\n      <td>164328200</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0</td>\n      <td>0.075819</td>\n    </tr>\n  </tbody>\n</table>\n<p>1170 rows × 6 columns</p>\n</div>",
            "text/plain": "            Adj Close     Volume  Increase_Decrease  Buy_Sell_on_Open  \\\nDate                                                                    \n2014-01-03   4.000000   22887200                  1                 1   \n2014-01-06   4.130000   42398300                  1                 1   \n2014-01-07   4.180000   42932100                  0                 1   \n2014-01-08   4.180000   30678700                  0                 0   \n2014-01-09   4.090000   30667600                  0                 0   \n2014-01-10   4.170000   20840800                  1                 1   \n2014-01-13   4.130000   22856100                  1                 0   \n2014-01-14   4.300000   42434800                  1                 1   \n2014-01-15   4.470000   66613100                  0                 1   \n2014-01-16   4.380000   46975600                  0                 0   \n2014-01-17   4.180000   45842700                  1                 1   \n2014-01-21   4.170000   58702900                  1                 0   \n2014-01-22   3.670000   86329500                  0                 0   \n2014-01-23   3.620000   29844700                  1                 0   \n2014-01-24   3.470000   48095800                  0                 0   \n2014-01-27   3.410000   31332300                  0                 0   \n2014-01-28   3.540000   27962600                  0                 1   \n2014-01-29   3.480000   21765000                  0                 0   \n2014-01-30   3.480000   17111700                  0                 0   \n2014-01-31   3.430000   13602100                  1                 0   \n2014-02-03   3.330000   22280200                  1                 0   \n2014-02-04   3.370000   22681000                  0                 1   \n2014-02-05   3.310000   14858900                  1                 0   \n2014-02-06   3.410000   16072900                  1                 1   \n2014-02-07   3.470000   23119700                  0                 1   \n2014-02-10   3.630000   21241100                  1                 1   \n2014-02-11   3.700000   34198100                  0                 1   \n2014-02-12   3.690000   18321300                  0                 0   \n2014-02-13   3.700000   13368600                  0                 1   \n2014-02-14   3.690000   12387900                  0                 0   \n...               ...        ...                ...               ...   \n2018-07-16  16.580000   65275300                  0                 1   \n2018-07-17  16.870001   42313500                  0                 1   \n2018-07-18  16.850000   40881500                  1                 0   \n2018-07-19  16.709999   41267800                  1                 0   \n2018-07-20  16.500000   42879800                  1                 0   \n2018-07-23  16.660000   44940800                  1                 1   \n2018-07-24  16.190001   58201500                  1                 0   \n2018-07-25  16.049999   82604900                  1                 1   \n2018-07-26  18.350000  192661100                  0                 1   \n2018-07-27  18.940001  161903800                  0                 1   \n2018-07-30  19.420000  160823400                  0                 0   \n2018-07-31  18.330000  118403400                  0                 0   \n2018-08-01  18.480000   75495200                  0                 0   \n2018-08-02  18.790001   52867100                  1                 1   \n2018-08-03  18.490000   53232100                  1                 0   \n2018-08-06  19.430000   83579700                  0                 1   \n2018-08-07  19.559999   72822600                  0                 0   \n2018-08-08  19.580000   52081400                  0                 1   \n2018-08-09  19.100000   46653400                  1                 0   \n2018-08-10  19.059999   65821100                  1                 1   \n2018-08-13  19.730000   81411300                  1                 1   \n2018-08-14  20.020000   89195500                  0                 0   \n2018-08-15  19.700001   86355700                  0                 0   \n2018-08-16  19.330000   69733700                  0                 0   \n2018-08-17  19.770000   60616600                  1                 1   \n2018-08-20  19.980000   62983200                  0                 1   \n2018-08-21  20.400000   55629000                  1                 1   \n2018-08-22  20.900000   62002700                  1                 1   \n2018-08-23  22.290001  113444100                  1                 1   \n2018-08-24  23.980000  164328200                  0                 0   \n\n            Buy_Sell   Returns  \nDate                            \n2014-01-03         1  0.012658  \n2014-01-06         1  0.032500  \n2014-01-07         0  0.012106  \n2014-01-08         0  0.000000  \n2014-01-09         1 -0.021531  \n2014-01-10         0  0.019560  \n2014-01-13         1 -0.009592  \n2014-01-14         1  0.041162  \n2014-01-15         0  0.039535  \n2014-01-16         0 -0.020134  \n2014-01-17         0 -0.045662  \n2014-01-21         0 -0.002392  \n2014-01-22         0 -0.119904  \n2014-01-23         0 -0.013624  \n2014-01-24         0 -0.041436  \n2014-01-27         1 -0.017291  \n2014-01-28         0  0.038123  \n2014-01-29         0 -0.016949  \n2014-01-30         0  0.000000  \n2014-01-31         0 -0.014368  \n2014-02-03         1 -0.029155  \n2014-02-04         0  0.012012  \n2014-02-05         1 -0.017804  \n2014-02-06         1  0.030212  \n2014-02-07         1  0.017595  \n2014-02-10         1  0.046110  \n2014-02-11         0  0.019284  \n2014-02-12         1 -0.002703  \n2014-02-13         0  0.002710  \n2014-02-14         1 -0.002703  \n...              ...       ...  \n2018-07-16         1  0.019053  \n2018-07-17         0  0.017491  \n2018-07-18         0 -0.001186  \n2018-07-19         0 -0.008309  \n2018-07-20         1 -0.012567  \n2018-07-23         0  0.009697  \n2018-07-24         0 -0.028211  \n2018-07-25         1 -0.008647  \n2018-07-26         1  0.143302  \n2018-07-27         1  0.032153  \n2018-07-30         0  0.025343  \n2018-07-31         1 -0.056128  \n2018-08-01         1  0.008183  \n2018-08-02         0  0.016775  \n2018-08-03         1 -0.015966  \n2018-08-06         1  0.050838  \n2018-08-07         1  0.006691  \n2018-08-08         0  0.001023  \n2018-08-09         0 -0.024515  \n2018-08-10         1 -0.002094  \n2018-08-13         1  0.035152  \n2018-08-14         0  0.014698  \n2018-08-15         0 -0.015984  \n2018-08-16         1 -0.018782  \n2018-08-17         1  0.022763  \n2018-08-20         1  0.010622  \n2018-08-21         1  0.021021  \n2018-08-22         1  0.024510  \n2018-08-23         1  0.066507  \n2018-08-24         0  0.075819  \n\n[1170 rows x 6 columns]"
          },
          "metadata": {}
        }
      ],
      "execution_count": 5,
      "metadata": {
        "collapsed": true,
        "jupyter": {
          "source_hidden": false,
          "outputs_hidden": false
        },
        "nteract": {
          "transient": {
            "deleting": false
          }
        },
        "execution": {
          "iopub.status.busy": "2020-09-04T02:06:06.965Z",
          "iopub.execute_input": "2020-09-04T02:06:06.973Z",
          "iopub.status.idle": "2020-09-04T02:06:06.986Z",
          "shell.execute_reply": "2020-09-04T02:06:07.031Z"
        }
      }
    }
  ],
  "metadata": {
    "kernel_info": {
      "name": "python3"
    },
    "language_info": {
      "nbconvert_exporter": "python",
      "name": "python",
      "file_extension": ".py",
      "version": "3.5.5",
      "mimetype": "text/x-python",
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "pygments_lexer": "ipython3"
    },
    "kernelspec": {
      "name": "python3",
      "language": "python",
      "display_name": "Python 3"
    },
    "nteract": {
      "version": "0.25.0"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 4
}